package com.wuage.infrastructure.exception;


/**
 * @author Shynin
 * @version 1.0
 */
public class BizException extends RuntimeException {
    private Integer errorCode;
    private String errorMsg;

    public BizException(Integer errorCode, String errorMsg) {
        super(String.format("BizException{errorCode:%s, errorMsg:%s}", errorCode, errorMsg));
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BizException(Integer errorCode, String errorMsg, Throwable cause) {
        super(String.format("BizException{errorCode:%s, errorMsg:%s}", errorCode, errorMsg), cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BizException(ResultCode resultCode) {
        super(String.format("BizException{errorCode:%s, errorMsg:%s}", resultCode.getCode(), resultCode.getDesc()));
        this.errorCode = resultCode.getCode();
        this.errorMsg = resultCode.getDesc();
    }

    public BizException(ResultCode resultCode, Throwable cause) {
        super(String.format("BizException{errorCode:%s, errorMsg:%s}", resultCode.getCode(), resultCode.getDesc()), cause);
        this.errorCode = resultCode.getCode();
        this.errorMsg = resultCode.getDesc();
    }

    public Integer getErrorCode() {
        return this.errorCode;
    }

    public String getErrorMsg() {
        return this.errorMsg;
    }
}
